public class Test3 {
    //二分查找
    public static void main(String[] args) {
        int []array = {1, 2, 2, 4, 5, 5, 9, 22, 623, 624, 2636};
        System.out.println(HSearch(array,9));
    }
    public static int HSearch(int []array, int n)  {
        int left = 0;
        int right = array.length-1;
        int tmp = 0;
        while(right > left) {
            if(n > array[(right+left)/2]) {
                left = (right+left)/2;
            } if(n <array[(right+left)/2]) {
                right = (right+left)/2;
            } else {
                tmp = (right+left)/2;
                break;
            }
        }
        return tmp;
    }
}
